/*
 * File: FltLevelSettingT.c
 *
 * Code generated for Simulink model 'FLTM'.
 *
 * Model version                  : 3.719
 * Simulink Coder version         : 9.4 (R2020b) 29-Jul-2020
 * C/C++ source code generated on : Fri Dec 29 09:53:44 2023
 */

#include "FltLevelSettingT.h"

/* Named constants for Chart: '<S46>/FetLevelSet' */
#define IN_Err_LV1                     ((uint8_T)1U)
#define IN_Err_LV2                     ((uint8_T)2U)
#define IN_Err_LV3                     ((uint8_T)3U)
#define IN_Err_Nor                     ((uint8_T)4U)
#define IN_Init                        ((uint8_T)5U)

/*
 * Output and update for atomic system:
 *    'FetLevelSet' ('mylib:133')
 *    'FetLevelSet' ('mylib:133')
 *    'FetLevelSet' ('mylib:133')
 */
void FltLevelSettingT(boolean_T LV1Cel, boolean_T LV1Cfm, boolean_T LV2Cel,
                      boolean_T LV2Cfm, boolean_T LV3Cel, boolean_T LV3Cfm,
                      B_FltLevelSettingT_T *localB, DW_FltLevelSettingT_T
                      *localDW, uint8_T rtp_Flttye)
{
    boolean_T tmp;
    if (localDW->is_active_c1_mylib == 0U)
    {
        localDW->is_active_c1_mylib = 1U;
        localDW->is_c1_mylib = IN_Init;
        localB->ScFlt_LV = 0U;
    }
    else
    {
        switch (localDW->is_c1_mylib)
        {
          case IN_Err_LV1:
            localB->ScFlt_LV = 1U;
            if (LV3Cfm)
            {
                localDW->is_c1_mylib = IN_Err_LV3;
                localB->ScFlt_LV = 3U;
            }
            else if (LV2Cfm)
            {
                localDW->is_c1_mylib = IN_Err_LV2;
                localB->ScFlt_LV = 2U;
            }
            else
            {
                if (LV1Cel)
                {
                    localDW->is_c1_mylib = IN_Err_Nor;
                    localB->ScFlt_LV = 0U;
                }
            }
            break;

          case IN_Err_LV2:
            localB->ScFlt_LV = 2U;
            if (LV3Cfm)
            {
                localDW->is_c1_mylib = IN_Err_LV3;
                localB->ScFlt_LV = 3U;
            }
            else if (LV2Cel && (!LV1Cfm))
            {
                localDW->is_c1_mylib = IN_Err_Nor;
                localB->ScFlt_LV = 0U;
            }
            else
            {
                if (LV2Cel)
                {
                    localDW->is_c1_mylib = IN_Err_LV1;
                    localB->ScFlt_LV = 1U;
                }
            }
            break;

          case IN_Err_LV3:
            localB->ScFlt_LV = 3U;
            tmp = !LV2Cfm;
            if (LV3Cel && (!LV1Cfm) && tmp)
            {
                localDW->is_c1_mylib = IN_Err_Nor;
                localB->ScFlt_LV = 0U;
            }
            else if (LV3Cel && LV1Cfm && tmp)
            {
                localDW->is_c1_mylib = IN_Err_LV1;
                localB->ScFlt_LV = 1U;
            }
            else
            {
                if (LV3Cel)
                {
                    localDW->is_c1_mylib = IN_Err_LV2;
                    localB->ScFlt_LV = 2U;
                }
            }
            break;

          case IN_Err_Nor:
            localB->ScFlt_LV = 0U;
            if (LV3Cfm)
            {
                localDW->is_c1_mylib = IN_Err_LV3;
                localB->ScFlt_LV = 3U;
            }
            else if (LV2Cfm)
            {
                localDW->is_c1_mylib = IN_Err_LV2;
                localB->ScFlt_LV = 2U;
            }
            else
            {
                if (LV1Cfm)
                {
                    localDW->is_c1_mylib = IN_Err_LV1;
                    localB->ScFlt_LV = 1U;
                }
            }
            break;

          default:
            /* case IN_Init: */
            localB->ScFlt_LV = 0U;
            if (rtp_Flttye == 1)
            {
                localDW->is_c1_mylib = IN_Err_Nor;
                localB->ScFlt_LV = 0U;
            }
            break;
        }
    }
}

/*
 * File trailer for generated code.
 *
 * [EOF]
 */
